package com.wf.feign;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created by wufei on 2017/8/8.
 */
@FeignClient(name = "provide-user",fallback = UserFeignClientFallback.class)
public interface UserFeignClient {

    @RequestMapping("user/{id}")
    User findByid(@RequestParam("id") Long id);

}

@Component
class UserFeignClientFallback implements UserFeignClient{

    @Override
    public User findByid(@RequestParam("id") Long id) {
        User user = new User();
        user.setId(-1L);
        user.setAge(0);
        user.setUsername("i am not");
        return user;
    }
}